package jas.bank;

import jas.rpc.Remote;
import jas.rpc.RemoteException;

/**
 * Provides access to name and balance of a bank account.
 * 
 * Modifications in balance are automatically propagated to the server.
 */
public interface Account extends Remote {
    /**
     * Get the name of the account.
     * @return
     * @throws jas.rpc.RemoteException
     */
    String getName() throws RemoteException;
    
    /**
     * Gets the current balance of the account. Each call results in a
     * server request, blocking until a response is received.
     * @return amount of cash in the account
     * @throws jas.rpc.RemoteException
     */
    double getBalance() throws RemoteException;
    
    /**
     * Increases the balance of the account. Blocks until server accepts.
     * @param amount: positive amount of cash to deposit.
     * @throws jas.rpc.RemoteException
     */
    void deposit(Double amount) throws RemoteException;
    
    /**
     * Decreases the balance of the account. Blocks until server accepts.
     * @param amount: Positive amount of cash to withdraw.
     * @throws jas.rpc.RemoteException
     */
    void withdraw(Double amount) throws RemoteException;
}
